package com.gaofans.nrpc.common.compress;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author GaoFans
 */
public class CodecFactory {

    public static final byte IDENTITY = 0;
    public static final byte GZIP = 1;
    public static final Map<Byte,Codec> CODECS = new ConcurrentHashMap<>();

    static {
        CODECS.put(GZIP,new GzipCodec());
        CODECS.put(IDENTITY,new Identity());
    }

    public static void register(byte type,Codec codec){
        CODECS.put(type,codec);
    }

    public static Codec remove(byte type){
        return CODECS.remove(type);
    }

    public static Codec get(byte type){
        return CODECS.get(type);
    }
}
